#pragma once
#include<iostream>
#include<string>
using namespace std;

//计算器
class Calculator
{
public:
    bool Calculate(const int left,const char oper,const int right,int& result)
    {
        switch(oper)
        {
            case '+':
            result=left+right;
            break;

            case '-':
            result=left-right;
            break;

            case '*':
            result=left*right;
            break;

            case '/':
            if(right==0)
            {
                result=0;
                cerr<<"除0错误"<<endl;
                return false;
            }
            result=left/right;
            break;

            case '%':
            if(right==0)
            {
                result=0;
                cerr<<"模0错误"<<endl;
                return false;
            }
            result=left%right;
            break;

            default:
            cerr<<"未知运算符"<<endl;
            result=0;
            return false;
        }
        return true;
    }
};